images=df['ImageName'] imgCode = [] for imgPath in images: image = PILImage.open(imgPath) output = io.BytesIO() image.save(output, format='png') encoded_string = "data:image/jpeg;base64,"+base64.b64encode(output.getvalue()).decode() imgCode.append(encoded_string) df['image'] = imgCode

# Resize images and encode them to base64 def resize_and_encode_image(image_path, size=(300, 300)): image = PILImage.open(image_path) image = image.resize(size) # Resize image to the desired size output = io.BytesIO() image.save(output, format='jpeg') # Use JPEG if you are encoding as jpeg encoded_string = "data:image/jpeg;base64," + base64.b64encode(output.getvalue()).decode() return encoded_string df['image'] = df['ImageName'].apply(lambda x: resize_and_encode_image(x))

import io import base64 import numpy as np import pandas as pd from PIL import Image as PILImage import matplotlib.pyplot as plt import matplotlib.cm as cm mul = 6 # Resize, rotate, and encode images to base64 with thermal-like effect def resize_rotate_and_encode_image(image_path, size=(mul*24, mul*32)): image = PILImage.open(image_path) image = image.resize(size) # Resize image to the desired size image = image.rotate(-90, expand=True) # Rotate image 90 degrees clockwise # Convert to grayscale gray_image = image.convert('L') # Apply colormap gray_array = np.array(gray_image) colored_image = cm.inferno(gray_array / 255.0) # Normalize the array and apply colormap colored_image = (colored_image[:, :, :3] * 255).astype(np.uint8) # Convert to 8-bit RGB image # Convert back to PIL image thermal_image = PILImage.fromarray(colored_image) # Encode to base64 output = io.BytesIO() thermal_image.save(output, format='jpeg') # Use JPEG if you are encoding as jpeg encoded_string = "data:image/jpeg;base64," + base64.b64encode(output.getvalue()).decode() return encoded_string # Assuming df is your DataFrame and it contains an 'ImageName' column with image paths df['image'] = df['ImageName'].apply(lambda x: resize_rotate_and_encode_image(x))

import io import base64 import numpy as np import pandas as pd from PIL import Image as PILImage import matplotlib.pyplot as plt import matplotlib.cm as cm # Resize, rotate, and encode images to base64 with thermal-like effect def resize_rotate_and_encode_image(image_path, small_size=(24, 32), final_size=(100, 100)): # Open the image image = PILImage.open(image_path) # Resize image to 24x32 small_image = image.resize(small_size) # Convert to grayscale gray_image = small_image.convert('L') # Apply colormap gray_array = np.array(gray_image) colored_image = cm.inferno(gray_array / 255.0) # Normalize the array and apply colormap colored_image = (colored_image[:, :, :3] * 255).astype(np.uint8) # Convert to 8-bit RGB image # Convert back to PIL image thermal_image = PILImage.fromarray(colored_image) # Resize thermal image to 250x250 enlarged_thermal_image = thermal_image.resize(final_size, PILImage.NEAREST) # Rotate image 90 degrees clockwise final_image = enlarged_thermal_image.rotate(-90, expand=True) # Encode to base64 output = io.BytesIO() final_image.save(output, format='jpeg') # Use JPEG if you are encoding as jpeg encoded_string = "data:image/jpeg;base64," + base64.b64encode(output.getvalue()).decode() return encoded_string # Assuming df is your DataFrame and it contains an 'ImageName' column with image paths df['image'] = df['ImageName'].apply(lambda x: resize_rotate_and_encode_image(x))

SAVE # Brush for selection brush = alt.selection_interval() # Main chart with dots and a dotted line points = alt.Chart(df).mark_circle(size=200).encode( alt.X('Test_number:Q', scale=alt.Scale(domain=(0, 100))), alt.Y('NDVI:Q', scale=alt.Scale(domain=(0.0, 1))), color=alt.Color('Test:N', scale=alt.Scale(scheme='tableau20')), # Vivid colors using tableau20 scheme tooltip=['image:N'] ).properties( width=1000, height=500, title='NDVI by STELLA Reading' ).add_selection( brush ) line1 = alt.Chart(df).mark_line(strokeDash=[5, 5]).encode( alt.X('Test_number:Q'), alt.Y('NDVI:Q') ) line2 = alt.Chart(df).mark_line(strokeDash=[5, 5]).encode( alt.X('Test_number:Q'), alt.Y('NDVI:Q'), color=alt.Color('Test:N', scale=alt.Scale(scheme='tableau20')) # Vivid colors for the line ) chart = alt.layer(points, line1, line2).resolve_scale(y='shared') # Image chart imgs = alt.Chart(df).mark_image(width=50, height=50).encode( url='image:N' ).facet( alt.Facet('Test:N', title='Select STELLA Reading', header=alt.Header(labelFontSize=0)), columns=2 ).transform_filter( brush ).transform_window( row_number='row_number()' ).transform_window( rank='rank(row_number)' ).transform_filter( alt.datum.rank < 15 ) # Combine the charts chart | imgs

# Brush for selection brush = alt.selection_interval() # Main chart with dots and a dotted line points = alt.Chart(df).mark_circle(size=100).encode( alt.X('Test_number:Q', scale=alt.Scale(domain=(0, 100))), alt.Y('NDVI:Q', scale=alt.Scale(domain=(0.0, 1))), tooltip=['image:N'] ).properties( width=1000, height=500, title='NDVI by STELLA Reading' ).add_selection( brush ) line = alt.Chart(df).mark_line(strokeDash=[5, 5]).encode( alt.X('Test_number:Q'), alt.Y('NDVI:Q') ) chart = alt.layer(points, line).resolve_scale(y='shared') # Image chart imgs = alt.Chart(df).mark_image(width=50, height=50).encode( url='image:N' ).facet( alt.Facet('Test:N', title='Select STELLA Reading', header=alt.Header(labelFontSize=0)), columns=2 ).transform_filter( brush ).transform_window( row_number='row_number()' ).transform_window( rank='rank(row_number)' ).transform_filter( alt.datum.rank < 15 ) # Combine the charts chart | imgs

import time import board import busio import adafruit_mlx90640 i2c = busio.I2C(board.SCL, board.SDA, frequency=800000) mlx = adafruit_mlx90640.MLX90640(i2c) print("MLX addr detected on I2C", [hex(i) for i in mlx.serial_number]) # if using higher refresh rates yields a 'too many retries' exception, # try decreasing this value to work with certain pi/camera combinations mlx.refresh_rate = adafruit_mlx90640.RefreshRate.REFRESH_2_HZ frame = [0] * 768 while True: try: mlx.getFrame(frame) except ValueError: # these happen, no biggie - retry continue for h in range(24): for w in range(32): t = frame[h*32 + w] print("%0.1f, " % t, end="") print() print()

import numpy as np import matplotlib.pyplot as plt # Step 1: Generate Sample Data # Create a 24x32 array with random temperature values between 20 and 40 degrees Celsius sample_data = np.random.uniform(20, 40, (24, 32)) # Step 2: Convert Data to Thermal Image plt.imshow(sample_data, cmap='inferno') plt.colorbar(label='Temperature (°C)') plt.title('Simulated Thermal Image') plt.show()

import numpy as np import matplotlib.pyplot as plt # Step 1: Generate Sample Data # Create a 24x32 array with random temperature values between 20 and 40 degrees Celsius sample_data = np.random.uniform(20, 40, (24, 32)) # Define a list of colormaps to use colormaps = ['inferno', 'plasma', 'hot', 'magma', 'jet'] # Step 2: Convert Data to Thermal Images using different colormaps fig, axs = plt.subplots(1, len(colormaps), figsize=(20, 5)) for ax, cmap in zip(axs, colormaps): im = ax.imshow(sample_data, cmap=cmap) ax.set_title(cmap) fig.colorbar(im, ax=ax, orientation='vertical', label='Temperature (°C)') plt.suptitle('Simulated Thermal Images with Different Colormaps') plt.show()